import random
from typing import *


class Solution:
    def minimumOperations(self, nums: List[int], target: List[int]) -> int:
        ans, l = 0, 0
        t = []
        c = []
        for a, b in zip(nums, target):
            d = a - b
            cur = abs(d)
            if l != 0:
                if d == 0:
                    cur = 0
                elif l > 0 and d > 0:
                    if d <= l:
                        cur = 0
                    else:
                        cur = d - l
                elif l < 0 and d < 0:
                    if d >= l:
                        cur = 0
                    else:
                        cur = l - d
            ans += cur
            l = d
        return ans


s = Solution()
print(
    s.minimumOperations(
        [
            50,
            37,
            98,
            51,
            88,
            57,
            71,
            47,
            60,
            100,
            78,
            37,
            31,
            20,
            39,
            25,
            52,
            78,
            94,
            67,
        ],
        [
            50,
            89,
            39,
            32,
            70,
            79,
            86,
            65,
            38,
            31,
            98,
            90,
            87,
            96,
            45,
            22,
            20,
            47,
            28,
            60,
        ],
    )
)

a, b = [], []
for _ in range(20):
    a.append(random.randint(10, 100))
    b.append(random.randint(10, 100))
print(a)
print(b)
